<template>
	<view class="content">
        <u-navbar bgColor="#fff" :fixed="true" :safeAreaInsetTop="true" :placeholder="true"
            @leftClick="back" title="单位详情" > <!-- 原为企业详情 据(基础信息优化工作20220326_APP优化)文档修改 -->
        </u-navbar>
        <view class="uni-shadow u-p-0 subsection">
            <u-subsection bgColor="#fff" fontSize="14" :list="tab" :current="current" @change="e=>current=e"></u-subsection>
        </view>

        <scroll-view scroll-y class="uni-area" :style="{height:swiperH+'px'}">
            <swiper class="swiper" :current="current" @change="e=>current=e.detail.current" >
                <!-- 企业信息 -->
                <swiper-item>
                    <view class="u-m-t-30 swiper-item">
                        <!-- 基本信息 -->
                        <uni-item-base :baseData="baseData" />
                        <!-- 附件 -->
                        <uni-accessory class="u-m-t-30" :accessorys="accessoryList"></uni-accessory>
                        <u-gap height="30rpx" bgColor="#FBFCFC"></u-gap>
                    </view>
                </swiper-item>

                <!-- 参建项目 -->
                <swiper-item>
                    <view class="u-m-t-30 swiper-item">
                        <view class="uni-shadow swiper-item-2">
                            <!-- title -->
                            <view class="u-flex u-m-b-30">
                                <view class="uni-line u-m-r-20"></view>
                                <text class="u-font-32 font-bold">基本信息</text>
                            </view>
                            <!-- 有数据 -->
                            <view v-for="(tem,ind) in cjProject" :key="ind" @tap.stop="projectDetail(tem.id)"
                                class="item u-p-l-40 u-p-r-30">
                                <view class="u-font-28 u-flex" style="width:100%">
                                    <text class="u-m-r-40">项目名称</text>
                                    <text class="uni-higt-color u-line-1" style="max-width:70%" @longtap="longTap(tem.xmmc)">
                                        {{tem.xmmc}}
                                    </text>
                                </view>
                                <u-icon name="arrow-right" color="#DFDFDF" size="12"></u-icon>
                            </view>
                            <!-- 无数据 -->
                            <view v-if="cjProject.length==0" class="u-m-t-30 swiper-item u-flex u-row-center u-flex-col">
                                <u--image src="/static/enterprise/empty.png" height="174px" style="margin-top:322rpx"></u--image>
                                <view class="u-flex u-row-center" style="margin-top:150rpx">
                                    <u-icon name="info-circle" size="24" class="u-m-r-20"></u-icon>
                                    <text class="u-font-32">暂无数据源</text>
                                </view>
                            </view>
                        </view>
                        <u-gap height="30rpx" bgColor="#FBFCFC"></u-gap>
                    </view>
                </swiper-item>

                <!-- 企业信用 -->
                <swiper-item>
                    <view class="u-m-t-30 swiper-item u-flex u-row-center u-flex-col">
                        <u--image src="/static/enterprise/empty.png" height="174px" style="margin-top:322rpx"></u--image>
                        <view class="u-flex u-row-center" style="margin-top:150rpx">
                            <u-icon name="info-circle" size="24" class="u-m-r-20"></u-icon>
                            <text class="u-font-32">暂无数据源</text>
                        </view>
                        <u-gap height="30rpx" bgColor="#FBFCFC"></u-gap>
                    </view>
                </swiper-item>
            </swiper>
        </scroll-view>

        <!-- 提示组件 -->
        <u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                systemInfo: uni.getStorageSync('systemInfo'),
                swiperH: 731,
                id: null, // 业务编号
				tab:['单位信息', '参建项目', '单位信用'], // 原为企业信息、企业信用 据(基础信息优化工作20220326_APP优化)文档修改 
                current: 0,
                // 基础信息
                baseData:{
                    line: true,
                    title: '基础信息',
                    list:[
                        // 原数据 据(基础信息优化工作20220326_APP优化)文档修改
                        // { fied:'qymc', title:'企业名称', value:'暂无数据' },
                        // { fied:'zjlx', title:'证件类型', value:'暂无数据' },
                        // { fied:'tyshxydm', title:'统一信用代码', value:'暂无数据' },
                        // { fied:'qyjydz', title:'单位地址', value:'暂无数据' },
                        // { fied:'qylx', title:'单位类型', value:'' },
                        // { fied:'districtName', title:'所属区划', value:'' },
                        // { fied:'zzlb', title:'主项资质类别', value:'' },
                        // { fied:'dj', title:'资质等级', value:'' },
                        // { fied:'frdb', title:'法人姓名', value:'' },
                        // { fied:'frdbzjhm', title:'证件号码', value:'' },
                        // { fied:'dwdh', title:'单位联系电话', value:'', type:'phone' },
                        // { fied:'qyczhm', title:'单位传真', value:'' },
                        // { fied:'dwdh', title:'手机号码', value:'15334527675', type:'phone' },
                        // { fied:'jydzyb', title:'邮政编码', value:'' },
                        // { fied:'rclxryx', title:'单位邮箱', value:'' },
                        { fied:'qymc', title:'单位名称', value:'安薪乐' },
                        { fied:'tyshxydm', title:'统一信用代码', value:'安薪乐' },
                        { fied:'qylx', title:'用户类型', value:'安薪乐' },
                        { fied:'dwlx1', title:'单位类型', value:'安薪乐' },
                        { fied:'zzdj', title:'资质等级', value:'安薪乐' },
                        { fied:'sdfl', title:'属地分类', value:'安薪乐' },
                        { fied:'qyjydz', title:'办公地址', value:'安薪乐' },
                        { fied:'zcdDistrictName', title:'注册地行政区划', value:'安薪乐' },
                        { fied:'qygszcszd', title:'注册地址', value:'安薪乐' },
                        { fied:'frdb', title:'法人姓名', value:'安薪乐' },
                        { fied:'frdbzjhm', title:'法人身份证号', value:'安薪乐'},
                        { fied:'frsjhm', title:'法人电话', value:'安薪乐', type:'phone' },
                        { fied:'currencytype', title:'注册币种', value:'安薪乐' },
                        { fied:'zczb', title:'注册资本(万元)', value:'安薪乐' },
                        { fied:'zcrq', title:'注册日期', value:'安薪乐' },
                        { fied:'jydzyb', title:'邮政编码', value:'安薪乐' },
                        { fied:'rclxryx', title:'单位邮箱', value:'安薪乐' },
                        { fied:'textarea', title:'备注', value:'安薪乐' },
                    ]
                },
                // 附件
                accessoryList:[],
                // 参建项目
                cjProject: []
			}
		},

        onReady(){
            uni.createSelectorQuery().in(this).select('.subsection').boundingClientRect(res => {
                this.swiperH = this.systemInfo.normalContentH - res.height
            }).exec();
        },


		onLoad(option) {
            this.id = option.id
            // 企业信息
            this.getEntInfo()
            // 企业信息附件
            this.getEntAccessory()
            // 参建项目
            this.getEntCanjianProject()
            // 企业信用
            this.getEntCct()
		},


		methods: {
            // 返回
            back(){
                uni.navigateBack()
            },
            // 长按事件
            longTap(value){
                this.$tools.uToast(this,'default','',value,3000)
            },
            // 项目详情
            projectDetail(id){
                uni.navigateTo({ url: '/pages/project-bag/detail?id='+id })
            },


            // 企业信息
            getEntInfo(){
                uni.showLoading({ title:'单位信息加载中' })
                const api = JSON.parse(JSON.stringify(this.$apis.entInfo))
                api.url = api.url+'/'+this.id
                this.$request(this, api, {}).then(res=>{
                    // console.log('企业信息',res)
                    this.baseData.list.map((v,i)=>{
                        v.value = res[v.fied]||res[v.fied]==0?res[v.fied]:'暂无数据源'
                    })
                }).then()
            },
            // 企业信息附件
            getEntAccessory(){
                uni.showLoading({ title:'单位信息附件加载中' }) 
                const parameter = {
                    ywlx: 'salary_core_dept_mx', // 业务类型【必传】
                    ywbh: this.id, // 业务编号【必传】
                }
                this.$request(this, this.$apis.CommonFjList, parameter).then(res=>{
                    // console.log('企业信息附件',res)
                    this.accessoryList = res
                }).then() 
            },
            
            // 参建项目
            getEntCanjianProject(){
                uni.showLoading({ title:'参建项目加载中' }) 
                this.$request(this, this.$apis.entCanjianProject, {qybm:this.id}).then(res=>{
                    // console.log('参建项目',res)
                    this.cjProject = res
                }).then() 
            },

            // 企业信用
            getEntCct(){
                uni.showLoading({ title:'单位信用加载中' }) 
                this.$request(this, this.$apis.entCct, {}).then(res=>{
                    // console.log('企业信用',res)
                }).then() 
            },
		}
	}
</script>

<style lang="scss">
    .content{
        .subsection{
            border: none;
        }
        .swiper{
            height: 100% !important;
            .swiper-item-2{
                .item{
                    height: 80rpx;
                    border: 1rpx solid #eee;
                    border-bottom: none;
                    display: flex !important;
                    justify-content: space-between !important;
                    &:nth-of-type(even){
                        background: #F6F7F8;
                    }
                    &:last-child{
                        border-bottom: 1rpx solid #eee;
                    }
                }
                .u-button--square{
                    border-bottom-left-radius: 0 !important;
                    border-bottom-right-radius: 0 !important;
                    border-top-left-radius: 0 !important;
                    border-top-right-radius: 0 !important;
                }
            }
        }
    }
</style>
